package com.hook3.pianke.activity.base;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.FrameLayout;
import android.widget.Toast;
import android.widget.Toolbar;

import com.hook3.pianke.R;

public class ToolbarActivity extends AppCompatActivity {
    private Toolbar toolbar_base;
    private FrameLayout fl_base_add;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_toolbar);
        toolbar_base = (Toolbar) findViewById(R.id.toolbar_base);
        fl_base_add = (FrameLayout) findViewById(R.id.fl_base_add);

//        toolbar_base.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
//            @Override
//            public boolean onMenuItemClick(MenuItem item) {
//                switch (item.getItemId()) {
//                    case R.id.btn_back_toolbar_menu:
//                        Toast.makeText(ToolbarActivity.this, "返回", Toast.LENGTH_LONG).show();
//                        break;
//                    case R.id.btn_talk_toolbar_menu:
//                        Toast.makeText(ToolbarActivity.this, "评论", Toast.LENGTH_LONG).show();
//                        break;
//                }
//            }
//        });
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_toolbar, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        } else if (id == R.id.btn_back_toolbar_menu) {
            Toast.makeText(ToolbarActivity.this, "返回", Toast.LENGTH_LONG).show();
        } else if(id ==R.id.btn_talk_toolbar_menu) {
            Toast.makeText(ToolbarActivity.this, "like", Toast.LENGTH_LONG).show();
        }


        return super.onOptionsItemSelected(item);
    }
}
